<?php
defined('IN_ADMIN') or exit('No permission resources.');
include $this->admin_tpl('header', 'admin');?>
<script type="text/javascript">
  $(document).ready(function() {
	$.formValidator.initConfig({autotip:true,formid:"myform",onerror:function(msg){}});
	$("#name").formValidator({onshow:"请输入品牌名称",onfocus:"品牌名称不能为空"}).inputValidator({min:1,max:999,onerror:"品牌名称不能为空"});
	$("#child").formValidator({onshow:"多个分类请用 , 隔开",onfocus:"多个分类请用 , 隔开"});
  })
</script>
<div class="pad_10">
<div class="common-form">
<form name="myform" action="?m=brand&c=brand&a=edit&bid=<?php echo $brand['id']; ?>&dosubmit=1" method="post" id="myform">
<table width="100%" class="table_form contentWrap">
<tr>
<td>品牌名称</td>
<td>
<input type="text" name="info[name]" value="<?php echo $brand['name']; ?>" class="input-text" id="name" size="30"></input>
</td>
</tr>

<tr>
<td>所属栏目</td>
<td>
<select name="info[catid_1]" id="catid_1">
	<?php 
	foreach ($cats AS $v) {
		echo "<option value='".$v['catid']."'".($cat_1['catid']==$v['catid'] ? " selected":"").">".$v['catname']."</option>";
	}
	?>
</select>
<select name="info[catid_2]" id="catid_2">
	<?php
	foreach ($cats AS $v) {
		if ($v['catid'] == $cat_1['catid']) {
			foreach ($v['child'] AS $v2) {
				echo "<option value='".$v2['catid']."'".($cat_2['catid']==$v2['catid'] ? " selected":"").">".$v2['catname']."</option>";
			}
		}
	}
	?>
</select>
</td>
</tr>

<tr>
<td>关联会员</td>
<td>
<select name="info[userid]">
<?php 
foreach ($members AS $u) {
	echo "<option value='".$u['userid']."'".($brand['userid']==$u['userid'] ? ' selected':'').">".$u['username']."</option>";
}
?>
</select>
</td>
</tr>

<tr>
	<td>供应商名称</td>
	<td><input type="text" name="info[pcompanyname]" value="<?php echo $brand['pcompanyname']; ?>" class="input-text" id="pcompanyname" size="30"></input></td>
</tr>

<tr>
	<td>联系人姓名</td>
	<td><input type="text" name="info[prealname]" value="<?php echo $brand['prealname']; ?>" class="input-text" id="prealname" size="30"></input></td>
</tr>

<tr>
	<td>联系人QQ</td>
	<td><input type="text" name="info[pqq]" value="<?php echo $brand['pqq']; ?>" class="input-text" id="pqq" size="30"></input></td>
</tr>

<tr>
	<td>联系人电话</td>
	<td><input type="text" name="info[ptel]" value="<?php echo $brand['ptel']; ?>" class="input-text" id="ptel" size="30"></input></td>
</tr>

<tr>
	<td>营销地址</td>
	<td><input type="text" name="info[paddress]" value="<?php echo $brand['paddress']; ?>" class="input-text" id="paddress" size="30"></input></td>
</tr>
</table>

    <div class="bk15"></div>
    <input name="dosubmit" type="submit" value="<?php echo L('submit')?>" class="dialog" id="dosubmit">
</form>
</div>
</div>
<script type="text/javascript">
var cats = <?php echo $cats_json; ?>;
$(function(){
	$("#catid_1").change(function(){
		var catid_1 = this.value;
		var html="";
		for(i in cats) {
			if(cats[i].catid == catid_1) {
				for(j in cats[i].child) {
					html += "<option value='"+cats[i].child[j].catid+"'>"+cats[i].child[j].catname+"</option>";
				}
				$("#catid_2").html(html);
			}
		}
	});
});
</script>
</body>
</html>